home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / loadscen.rex < prev    next >
OS/2 REXX Batch file  |  1994-11-03  |  4KB  |  204 lines

  1. /********************************************************************/
  2. /*                                                                  */
  3. /* Load from Scene V1.0                                             */
  4. /*                                                                  */
  5. /* Loads Objects from Lightwave Scene File                          */
  6. /*                                                                  */
  7. /* ⌐ 1994  By  AndrΘ Hotz    -=< Imaginative Systems >=-            */
  8. /*                                                                  */
  9. /********************************************************************/
  10.  
  11.  
  12. call AddLib "LWModelerARexx.port", 0
  13.  
  14. ver = 'V1.0'
  15.  
  16. name = 'Load from Scene '||ver
  17.  
  18. signal on error
  19. signal on syntax
  20.  
  21. layer = CurLayer()
  22.  
  23. scenename = GetFileName('Select Scene File:')
  24.  
  25. if scenename ~= '(none)' then do
  26.  
  27. call ReadScene()
  28.  
  29. call Req_Begin(name)
  30.  
  31. tid = Req_AddControl('Load Objects','CH','All' 'Selective')
  32. call Req_SetVal(tid,1)
  33. if (~Req_Post()) then do
  34.        call Req_End()
  35.       exit
  36. end
  37. typ = Req_GetVal(tid)
  38.  
  39. call Req_End()
  40.  
  41. do s=1 to n
  42.    obj.s = 1
  43. end
  44.  
  45. if typ = 2 then do
  46.  
  47. i=1
  48. a=1
  49. b=1
  50.  
  51. do until i=n+1
  52.  
  53.   call Req_Begin(name||' -- Select Objects to Load')
  54.  
  55.   do until ((i//15=0) | (i=n+1))
  56.    id.i = Req_AddControl(objectp.i,'B')
  57.    i=i+1
  58.   end
  59.  
  60.   do until ((a//15=0) | (a=n+1))
  61.    call Req_SetVal(id.a,0)
  62.    a=a+1
  63.   end
  64.  
  65.   if (~Req_Post()) then do
  66.           call Req_End()
  67.           exit
  68.   end
  69.  
  70.   do until ((b//15=0) | (b=n+1))
  71.     obj.b=0
  72.     if Req_GetVal(id.b)=1 then do
  73.       obj.b = 1
  74.     end
  75.     b=b+1
  76.   end
  77.  
  78.   call Req_End()
  79.  
  80. end
  81. end
  82.  
  83.  
  84. call CUT()
  85. call Sel_Mode(USER)
  86.  
  87. do i=1 to n
  88.   if obj.i = 1 then do
  89.   call SetLayer(layer+1)
  90.   call Cut()
  91.   call Load(objectp.i)
  92.  
  93.   parse var objectdata.i x y z rx ry rz sx sy sz
  94.  
  95.   movev  = x||' '||y||' '||z
  96.   scalev = sx||' '||sy||' '||sz
  97.  
  98.   call Scale(scalev,0)
  99.  
  100.  
  101.   call Rotate(-rx,'Y',0)
  102.   call Rotate(-ry,'X',0)
  103.   call Rotate(-rz,'Z',0)
  104.  
  105.   call Move(movev)
  106.  
  107.   a=i
  108.   ppos=i
  109.  
  110.   if parentobject.i ~= -1 then call ParentPos(i)
  111.  
  112.   call Sel_Polygon(CLEAR)
  113.   call Copy()
  114.   call SetLayer(layer)
  115.   call Paste()
  116.   end
  117. end
  118.  
  119. call Close(scene)
  120.  
  121. call Notify(1,'!Thanks for using Load from Scene '||ver,'','@⌐ 1994 By AndrΘ Hotz','@of','-=> Imaginative Systems <=-','-=> Productions <=-','')
  122.  
  123. end
  124.  
  125. call RemLib "LWModelerARexx.port"
  126. exit
  127.  
  128.  
  129.  
  130. ReadScene:
  131.  
  132. if Open(scene,scenename,'READ') then do
  133.    n=0
  134.    vergleich=0
  135.    do until vergleich=1
  136.       buffer = Readln(scene)
  137.       if word(buffer,1)='LoadObject' then do
  138.          n=n+1
  139.          parse var buffer 12 objectp.n
  140.          call GetObjInfo2()
  141.  
  142.       end
  143.       vergleich=0
  144.       if word(buffer,1)='AmbientColor' then vergleich=1
  145.    end
  146.    call Close(scene)
  147. end
  148. return
  149.  
  150. GetObjInfo2:
  151.  
  152.            do until word(buffer,1)='ObjectMotion'
  153.               buffer=Readln(scene)
  154.            end
  155.            buffer=Readln(scene)
  156.            buffer=Readln(scene)
  157.            objectdata.n=Readln(scene)
  158.  
  159.            do until word(buffer,1)='EndBehavior'
  160.               buffer=Readln(scene)
  161.            end
  162.            buffer=Readln(scene)
  163.            if word(buffer,1)='ParentObject' then parentobject.n=word(buffer,2)
  164.                 else parentobject.n= -1
  165.  
  166. return
  167.  
  168.  
  169. ParentPos: procedure expose a parentobject. objectdata. objectp.
  170.  
  171. arg ppos
  172. a = parentobject.ppos
  173.  
  174. if parentobject.ppos ~=-1 then do
  175.  
  176. nr = parentobject.ppos
  177.  
  178. parse var objectdata.nr x y z rx ry rz sx sy sz
  179.  
  180. movev  = x||' '||y||' '||z
  181. scalev = sx||' '||sy||' '||sz
  182.  
  183. call Scale(scalev,0)
  184.  
  185. call Rotate(-rx,'Y',0)
  186. call Rotate(-ry,'X',0)
  187. call Rotate(-rz,'Z',0)
  188.  
  189. call Move(movev)
  190.  
  191. call ParentPos(parentobject.ppos)
  192.  
  193. end
  194.  
  195. return
  196.  
  197.  
  198. syntax:
  199. error:
  200.   call end_all
  201.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  202.     exit
  203.  
  204.